﻿/*************************************************
Description:智能家居--主界面功能的实现
**************************************************/
#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QTimer>
#include <mymqtt.h>
class QToolButton;
class EntertainmentWidget;
class SystemSettingDialog;

class Parlourwidget;
class BedRoomWidget;


class StatisticWidget;
class SecurityWidget;
//class SecuritySetting;

class ReadSerialPortData;
class SaveDataThread;

namespace Ui {
class Widget;
}

class Widget : public QWidget
{
    Q_OBJECT

    //场景名称枚举
    enum enum_widget{
        E_Control_WIDGET = 0,       //控制主页
        E_HOME_WIDGET,              //首页
        E_PARLOUR_WIDGET = 2,       //客厅
        E_ENTERTAINMENT_WIDGET,     //娱乐
        E_BEDROOM_WIDGET,           //卧室
        E_TEMPTURE,
        E_SECURITY_WIDGET,          //安防管理界面
    };
    enum E_TEXTSIZE{
        E_NORMAL = 0,
        E_BIG = !E_NORMAL
    };
    
public:
    explicit Widget(QWidget *parent = 0);
    ~Widget();
    QMQTT::Client *client;


private:
    void initDataTime();                        //初始化系统日期和时间
    void initForm();                            //样式初始化
    void initWidget();                          //窗体初始化
    void initConnect();                         //信号和槽连接初始化
    void deletWidget();

    //设置按钮样式
    void setToolButtonStyle(QToolButton*tbn,const QString &text,int textSize,
                            const QString iconName);

private slots:
    void setCurrentWidget(enum_widget enum_widget_name);

    //设置当前时间
    void slotShowCurrentDataTime();
    //输出错误信息
    void slotErrorString(QString err);



protected:
    void keyPressEvent(QKeyEvent *);
    void mouseMoveEvent(QMouseEvent *);
    void mousePressEvent(QMouseEvent *);
    void mouseReleaseEvent(QMouseEvent*);
    
signals:
    void signalCloseSystem();
private slots:

    void on_tbnHome_clicked();
    void on_tbnStatistic_clicked();
    void on_tbnNight_clicked();

    void slot_receiveData(QByteArray);
    void on_tbnControl_clicked();
    void on_tbnSetting_clicked();
    void on_tbnRelaxation_clicked();

    void on_tbnCurtain_clicked();

private:
    Ui::Widget *ui;
    bool m_isPress;
    QPoint mousePoint;
    QRect location;
    SystemSettingDialog *m_settingDialog;           //设置界面
    Parlourwidget *m_parlourWidget;                 //客厅界面
    BedRoomWidget *m_bedRoomWidget;                 //卧室界面
    StatisticWidget *m_statisticWidget;             //统计界面
    EntertainmentWidget *m_entertainmentWidget;     //搜索设备界面
    SecurityWidget *m_securityWidget;               //安防监控界面
    MyMqtt *m_mymqttWidget;
    QTimer *m_timer;

    QString s_styleOn;
    QString s_styleOff;
    QString w_styleOn;
    QString w_styleOff;

};

#endif // WIDGET_H
